package com.bc.utils;

import android.content.Context;
import android.content.SharedPreferences;

public class SettingPrefs {
	public static final String PREF_NAME = "settings";
	public static final String REFRESH_TIME = "refresh_time";
	public static final String EXIT_SERVICE_ON = "exit_service_on";
	public static final String REFRESH_TIME_POSITION = "refresh_time_posi";
	private static SharedPreferences prefs;
	
	private static SettingPrefs settingPrefs;

	private SettingPrefs(Context context) { 
		if (prefs == null) {
			prefs = context.getSharedPreferences(SettingPrefs.PREF_NAME, Context.MODE_PRIVATE);
		}
	}
	
	public SharedPreferences getPreferences() {
		return prefs;
	}
	
	public static SettingPrefs getInstance(Context context) {
		if (settingPrefs == null) {
			synchronized (SettingPrefs.class) {
				settingPrefs = new SettingPrefs(context);
			}
		}
		return settingPrefs;
	}
	
	public void putIntToPrefs(String key, int value) {
		prefs.edit().putInt(key, value).commit();
	}
	
	public int getIntFromPrefs(String key, int value) {
		return prefs.getInt(key, value);
	}
	
	public void putBooleanToPrefs(String key, boolean value) {
		prefs.edit().putBoolean(key, value).commit();
	}
	
	public boolean getBooleanFromPrefs(String key, boolean value) {
		return prefs.getBoolean(key, value);
	}
}
